package org.dreamwork.assistant.tools.network.gui;

import javax.swing.*;
import java.awt.*;
/**
 * Created by seth.yang on 2018/5/7
 */
public class CircleIcon extends ImageIcon {
    private static final int EDGE = 16;

    private int state = 0;

    @Override
    public synchronized void paintIcon (Component c, Graphics g, int x, int y) {
        g.clearRect (x, y, EDGE, EDGE);
        Color color = state == 0 ? Color.GRAY : Color.GREEN;
        g.setColor (color);
        g.fillArc (x, y, EDGE, EDGE, 0, 360);
    }

    @Override
    public int getIconWidth () {
        return EDGE;
    }

    @Override
    public int getIconHeight () {
        return EDGE;
    }

    public void setState (int state) {
        this.state = state;
    }

    public int getState () {
        return state;
    }
}